package com.atguigu.cloud.controller;

import com.atguigu.cloud.resp.ResultData;
import com.atguigu.cloud.service.StorageService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: interface
 * @Create: 2025/7/29 - 下午3:39
 */
@RestController
public class StorageController {

    @Resource
    private StorageService storageService;

    /**
     * 扣减库存
     */
    @RequestMapping("/storage/decrease")
    public ResultData decrease(Long productId, Integer count) {

        int result = storageService.decrease(productId, count);
        if (result > 0) {
            return ResultData.success("扣减库存成功!");
        }
        return ResultData.error("扣减库存失败!");

    }
}
